<?php
$captchaurl = "http://www.televisiontunes.com/captchaerror.php" ; 
require_once('recaptchalib.php');
$publickey = "6Leq8QYAAAAAACePJ7GEwuVKF3RMfdLui0AJD8iM ";
$privatekey = "6Leq8QYAAAAAAD9Vms-Q_TfhiEf1Q1PmmQyr-GNQ";
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
 // die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
 //      "(reCAPTCHA said: " . $resp->error . ")");
 header( "Location: $captchaurl" );
        exit ; 
      }

$Name = Trim(stripslashes($_POST['name'])); 
$Email = Trim(stripslashes($_POST['email'])); 
$Reason = Trim(stripslashes($_POST['reason'])); 
$Msg = Trim(stripslashes($_POST['message'])); 

$headers .= "From: <".$Email.">\n";
$headers .= "Content-type: text/html\n";
$EmailTo = "jayzoo@gmail.com";
$Subject = "TelevisionTunes Contact Form";


// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "<b>Name:</b> ";
$Body .= $Name;
$Body .= "<br>";
$Body .= "<b>Email:</b> ";
$Body .= $Email;
$Body .= "<br>";
$Body .= "<b>Reason:</b> ";
$Body .= $Reason;
$Body .= "<br>";
$Body .= "<b>Message:</b> ";
$Body .= nl2br($Msg);
$Body .= "<br>";

// send email 
$success = mail($EmailTo, $Subject, $Body, $headers);

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.televisiontunes.com/contactthanks.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>